package com.dream.inspect.modules.business.controller;

import com.dream.inspect.common.utils.PageUtils;
import com.dream.inspect.common.utils.R;
import com.dream.inspect.common.validator.ValidatorUtils;
import com.dream.inspect.modules.business.entity.SysXzqhbEntity;
import com.dream.inspect.modules.business.service.SysXzqhbService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 行政区划表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-06-16 17:04:57
 */
@RestController
@CrossOrigin
@RequestMapping("business/sysxzqhb")
public class SysXzqhbController {
    @Autowired
    private SysXzqhbService sysXzqhbService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("business:sysxzqhb:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysXzqhbService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{dm}")
    @RequiresPermissions("business:sysxzqhb:info")
    public R info(@PathVariable("dm") String dm){
        SysXzqhbEntity sysXzqhb = sysXzqhbService.selectById(dm);

        return R.ok().put("sysXzqhb", sysXzqhb);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:sysxzqhb:save")
    public R save(@RequestBody SysXzqhbEntity sysXzqhb){
        sysXzqhbService.insert(sysXzqhb);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("business:sysxzqhb:update")
    public R update(@RequestBody SysXzqhbEntity sysXzqhb){
        ValidatorUtils.validateEntity(sysXzqhb);
        sysXzqhbService.updateAllColumnById(sysXzqhb);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("business:sysxzqhb:delete")
    public R delete(@RequestBody String[] dms){
        sysXzqhbService.deleteBatchIds(Arrays.asList(dms));

        return R.ok();
    }

}
